//引入二次封装的axios
import { request2 } from '@/axios/request'
import type {
  AllMissionInfoResponseData,
  CodeListResponseData,
  SingleMissionInfoResponseData,
  DeleteCodeResponseData
} from './type'
//枚举地址
enum API {
  //获取编码赋码全部任务概况的接口
  MISSIONSTATE_URL = '/encodingByExcel/all',
  //按部门获取编码赋码任务概况的接口
  DEPARTMENT_MISSIONSTATE_URL = 'encodingByExcel/byDepartment/',
  //获取编码赋码单个任务详情的接口
  MISSIONINFO_URL = '/encodingByExcel/',
  // 下载编码赋码结果文件的接口
  DOWNLOADFILE_URL = '/encodingByExcel/download/',
  // 上传需要编码赋码文件的接口
  UPLOADFILE_URL = '/encodingByExcel/upload',
  // 获取编码赋码结果列表的接口
  CODELIST_URL = '/encodingresult/',
  // 注销单条编码赋码的接口
  DELETECODE_URL = '/encodingresult/cancellation/',
  // 获取已注销的编码赋码结果列表的接口
  DELETE_CODELIST_URL = '/encodingresult/canceled'
}
//提交订单
// export const reqMissionState = () => request.post<any, SubmitOrder>(API.SUBMITORDER_URL + `${hoscode}/${scheduleId}/${patientId}`);

//获取编码赋码全部任务概况
export const reqAllMission = (pageNum: number, pageSize: number) =>
  request2.get<any, AllMissionInfoResponseData>(
    API.MISSIONSTATE_URL + `?pageNum=${pageNum}&pageSize=${pageSize}`
  )

//按部门获取编码赋码任务概况
export const reqDepartmentMission = (department: string, pageNum: number, pageSize: number) =>
  request2.get<any, AllMissionInfoResponseData>(
    API.DEPARTMENT_MISSIONSTATE_URL + department + `?pageNum=${pageNum}&pageSize=${pageSize}`
  )

//获取编码赋码全部任务概况
export const reqMissionInfo = (id: string) =>
  request2.get<any, SingleMissionInfoResponseData>(API.MISSIONINFO_URL + id)

//下载编码赋码结果
export const downloadResult = (id: string) =>
  request2.get<any, Blob>(API.DOWNLOADFILE_URL + id, { responseType: 'blob' })

//上传编码赋码申请
export const uploadResult = (data: Record<string, any>) =>
  request2.post<any, any>(API.UPLOADFILE_URL, data, {
    headers: { 'Content-Type': 'multipart/form-data;' }
  })

// 获取编码赋码结果列表
export const reqCodeList = (department: string, pageNum: number, pageSize: number) =>
  request2.get<any, CodeListResponseData>(
    API.CODELIST_URL + department + `?pageNum=${pageNum}&pageSize=${pageSize}`
  )

// 删除单条编码赋码
export const deleteCode = (code: string, department: string) =>
  request2.post<any, DeleteCodeResponseData>(
    API.DELETECODE_URL + code + `?department=${department}`
  )

// 获取已注销的编码赋码结果列表
export const reqDeleteCodeList = (department: string, pageNum: number, pageSize: number) =>
  request2.get<any, CodeListResponseData>(
    API.DELETE_CODELIST_URL + `?pageNum=${pageNum}&pageSize=${pageSize}`
  )
